<!DOCTYPE html >
<html>
<head>
<meta name="Generator" content="tpshop" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>购物流程-{$tpshop_config['shop_info_store_title']}</title>
<meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
<meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<link rel="stylesheet" href="__STATIC__/css/public.css">
<link rel="stylesheet" href="__STATIC__/css/flow.css">
<link rel="stylesheet" href="__STATIC__/css/style_jm.css">
<script type="text/javascript" src="__STATIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/global.js"></script>
<script src="__PUBLIC__/js/mobile_common.js"></script>
<script src="__STATIC__/js/common.js"></script>
<link rel="stylesheet" href="__STATIC__/css/font-awesome.min.css">
<link rel="stylesheet" href="__STATIC__/css/icomoon.css">

</head>
<body style="background: rgb(235, 236, 237);position:relative;">

<div class="tab_nav tab_nav_none">
    <div class="header">
	<a href="javascript:void(0);" onClick="javascript:history.go(-1);" class="header_l"><i class="fa fa-angle-left"></i></a>
      <div class="h-mid">确认订单   </div>
	<a href="{:U('Index/index')}" class="header_r"><i class="fa fa-home"></i></a>

    </div>
</div>

<div class="screen-wrap fullscreen login">
<form name="cart2_form" id="cart2_form" method="post">


    <input name="hd_id" id="hd_id" value="{$hd_id}" type="hidden"/>
    <section class="content" style="min-height: 294px;">
    <div class="wrap">
    <div class="active" style="min-height: 294px;">
    <div class="content-buy">
    <div class="wrap order-buy">

    <div id="ajax_address">
    <a href="{:U('User/address_list',array('source'=>'cart2'))}">
	    <section class="address">
	      <div class="address-info" >收货人:
	        <p class="address-name">{$address.consignee}</p>
	        <p class="address-phone">{$address.mobile}</p>
	      </div>
	      <div class="address-details">收货地址：{$address.address}</div>
          <input type="hidden" value="{$address.address_id}" name="address_id" />
	    </section>
    </a>
    </div>

    <section class="order " id="order4">
      <div  class="order-info" style="margin-top:0;">
      <!--
        	<h4 class="seller-name" > <img src="__STATIC__/images/flow/dingdan.png" width="28">
        		订单详情 <a class="modify" href="{:U('Cart/cart')}">修改</a></h4>
      -->
      </div>
 <if condition="$promname">
          <div id="cart_top" style="margin-bottom: 0;">
        <span style="font-size: 12px;">优惠：{$promname}</span>

	 </div></if>


      <section class="order-info" style=" margin-top:0px;">
        <div class="order-list">
          <div class="goods-list-title" style="font-size: 12px;font-weight: normal;">&nbsp;&nbsp; <if condition="$total_price.yh_total neq 0"> 总价：¥ {$total_price.total_header_fee}&nbsp;&nbsp;<em>减：¥ {$total_price.yh_total}</em></if></div>
          <ul class="order-list-info">
           <foreach name="cartList" item="v"  key="k">
            <if condition="$v[selected] eq '1'">
            <li class="item" >
              <div class="itemPay list-price-nums" id="itemPay17">
                <p class="price">￥{$v.member_goods_price}元</p>
                <p class="nums">x{$v.goods_num}</p>
              </div>
              <div class="itemInfo list-info" id="itemInfo12">
                <div class="list-img"> <a href="{:U('Mobile/Goods/goodsInfo',array('id'=>$v[goods_id]))}"> <img src="{$v.goods_id|goods_thum_images=200,267}"></a> </div>
                <div class="list-cont">
                  <h5 class="goods-title">{$v.goods_name} </h5>
                  <p class="godds-specification">{$v.spec_key_name|orderdetailstr}</p>
                </div>
              </div>
            </li>
            </if>
            </foreach>
            <li class="flow_youhui_no" style="display:none;">如果是会员<font color=red></font>，可以享受会员折扣价</li>
            <li class="flow_youhui_no">
              <div class="checkout_other">
                <div class="jmbag" href="javascript:void(0);" onClick="showCheckoutOther(this);"><span class="right_arrow_flow"></span>使用优惠券</div>
                <table class="subbox_other sub_bonus" width="100%">
                  <tr>
                    <td  colspan="2">
                    <input type="radio" class="radio vam ma-ri-10" name="couponTypeSelect" checked value="1"  onClick="ajax_order_price();" />
                     <select id="coupon_id" name="coupon_id" class="vam ou-no" onChange="ajax_order_price();">
                         <option value="0">选择优惠券</option>
                          <foreach name="couponList" item="v"  key="k">
                            <option value="{$v['id']}">{$v['name']}</option>
                          </foreach>
                     </select>
                    </td>
                    <td>
                   <!--  &nbsp;或 &nbsp;
                    <input type="radio" class="radio vam ma-ri-10" name="couponTypeSelect"  value="2"  onClick="ajax_order_price();javascript:document.getElementById('Bonus_span_0').style.display='block';" />
                    <a href="javascript:void(0);"  class="a_other1_h" id="Bonus_a_0">直接输入优惠券号</a> -->
                    </td>
                    <td>
                      <label id="Bonus_span_0" style="display:none;">
                        <input name="couponCode" id="bonus_sn_0" type="text"   value="" placeholder="输入优惠券"  class="txt1" style="width:100px;"/>
                        <input name="validate_bonus" type="button" value="使用" onClick="ajax_order_price();" class="BonusButton" />
                      </label>
                    </td>
                  </tr>
                </table>
              </div>
            </li>
            <li class="flow_youhui_no">
       			<label id="Bonus_span_0">
       			   使用余额：
                   <input id="user_money" name="user_money"  type="text"   placeholder="输入余额" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" class="txt1" style="width:100px;"/>
                   <input name="validate_bonus" type="button" value="使用" onClick="ajax_order_price();" class="BonusButton" />
                 	可用余额<em>{$user['user_money']}</em>
                 </label>
            </li>

            <li class="flow_youhui_no">
       			<label id="Bonus_span_0">
       			   使用积分：
                   <input id="pay_points" name="pay_points" type="text"   placeholder="输入积分"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" class="txt1" style="width:100px;"/>
                   <input name="validate_bonus" type="button" value="使用" onClick="ajax_order_price();" class="BonusButton" />
                 	可用积分<em>{$user['pay_points']}</em>
                 </label>
            </li>
          </ul>
        </div>
      </section>
    </section>
      <section class="order-info">
          <div class="order-list">
            <div class="content ptop0">
              <div class="panel panel-default info-box">
                <div class="panel-body" id="pay_div"  >
                  <div class="title" id="zhifutitle" style="border-bottom:1px solid #eeeeee;">
                  	<span class="i-icon-arrow-down i-icon-arrow-up" id="zhifuip"></span>
                   	<span class="text">配送方式</span>
                   	<em class="qxz" id="emzhifu">请选择配送方式</em>
                  </div>
                   <ul class="nav nav-list-sidenav" id="zhifu68" style="display:block; border-bottom:none;">
                   <foreach name="shippingList" item="v"  key="k">
                    <li class="clearfix" name="payment_name">
                      <label>
                      <input type="radio" id="{$v.code}" name="shipping_code" id="{$v.code}" value="{$v.code}" style="margin-top:4px;margin-right:8px;<if condition="$k neq 0">margin-bottom:20px;</if>"  <if condition="$k eq 0"> checked="checked" </if> onclick="ajax_order_price()" class="c_checkbox_t"/>{$v.name}  <if condition="$v.code eq 'smzt'">({$v.desc})</if>
                      <!-- <div class="fl shipping_title"></div> -->
                      </label>
                    </li>
                    </foreach>
                  </ul>
                </div>
              </div>
            </div>
          </div>
        </section>
   <section class="order-info"  style="display:none;">
    <div class="order-list">
      <div class="content ptop0">
        <div class="panel panel-default info-box">
          <div class="orderInfo " >
            <h4 class="seller-name">  其他选项 </h4>
          </div>
          <table border=0 cellpadding=0 cellspacing=0 width="100%" class="checkgoods">
            <tr>
              <td colspan=4 class="tdother2" style="border-top:none;"><div class="checkout_other" >
                  <div class="jmbag" href="javascript:void(0);" onClick="showCheckoutOther(this);"><span class="right_arrow_flow"></span>开发票和缺货处理</div>
                  <div class="subbox_other" width="100%">
                    <table id='normal_invoice_tbody' width="100%">
                      <tr>
                        <td align=right style="vertical-align:top" width="84">发票抬头：</td>
                        <td colspan="2">
                          <input class="txt1" style='vertical-align:middle' type="text" name="invoice_title" placeholder="XXX单位 或 XX个人" />
                        </td>
                      </tr>
                    </table>
                  </div>
                </div>
                </td>
            </tr>
          </table>
        	<div style="height:10px; line-height:10px; clear:both;"></div>
        </div></div></div>
        </section>
        <section class="order-info">
        <div class="order-list">
          <div class="content ptop0">
            <div class="panel panel-default info-box">
              <div class="con-ct fo-con">
                <ul class="ct-list order_total_ul" id="ECS_ORDERTOTAL" >
                  <li class="order_total_li" >
                  		*该订单完成后，您将获得 <span class="price">相应的</span> 积分<br/>
                  </li>
                  <li>

                   <div class="subtotal">
                      <span class="total-text">商品总额：</span>￥<em class="price" id="order-cost-area"> {$total_price.total_header_fee} 元</em><br/>
                      <span class="total-text">配送费用：</span>￥<em class="price" id="postFee">
                       <!--{$total_price.shipping_price}-->
                       0.00</em><br/>
                      <span class="total-text">使用优惠券：</span>-&nbsp;¥&nbsp;<em class="price" id="couponFee">0.00</em><br/>
                      <span class="total-text">使用积分：</span>-&nbsp;¥&nbsp;<em class="price" id="pointsFee">0.00</em><br/>
                      <span class="total-text">使用余额：</span>-&nbsp;¥&nbsp;<em class="price" id="balance">0.00</em><br/>
                      <span class="total-text"> 优惠活动 ：</span>-&nbsp;¥&nbsp;<em class="price" id="order_prom_amount">{$total_price[yh_total]}</em><br/>
                      <span class="total-text">应付 金额：</span>￥<strong class="price_total" id="payables">{$total_price.total_fee} </strong>
                      <span class="total-text" style=""></span>
                   </div>
                  </li>
                </ul>
              </div>
              <div class="panel panel-default info-box">
                <div class="pay-btn">
                  <input onClick="submit_order();" type="button" class="sub-btn btnRadius" value="提交订单"/>
                </div>
              </div>
            </div>
            </div>
            </div>
         </section>
         </div>
        </div>
      </div>
    </div>
 	</section>
  </form>
  </div>
<section class="f_mask" style="display: none;"></section>

<div style="display: none;">
<form action="{:U('Mobile/Payment/getCode')}" method="post" name="cart4_form" id="cart4_form">
	<input type="radio" value="pay_code=weixin" checked="checked" name="pay_radio" />
	<input type="text" name="order_id" id="order_id" value="{$order['order_id']}" />
</form>
</div>


<script type="text/javascript">

    $(document).ready(function(){
        //ajax_order_price(); // 计算订单价钱
		ajax_address();
    });

function gopayweixin(id){
		$('#order_id').val(id);
        $('#cart4_form').submit();
        return;
}

// 获取订单价格
function ajax_order_price()
{



    var hd_id = $('#hd_id').val();
    $.ajax({
        type : "POST",
        url:'/index.php?m=Mobile&c=Cart&a=cart3&act=order_price&hd_id='+hd_id+'&t='+Math.random(),
        data : $('#cart2_form').serialize()+"&nosubmit=1",
        dataType: "json",
        success: function(data){

            if(data.status != 1)
            {
                alert(data.msg);
                // 登录超时
                if(data.status == -100)
                    location.href ="{:U('Mobile/User/login')}";

                return false;
            }
            // console.log(data);
			$("#order-cost-area").text(data.result.goodsFee);
            $("#postFee").text(data.result.postFee); // 物流费
            $("#couponFee").text(data.result.couponFee);// 优惠券
            $("#balance").text(data.result.balance);// 余额
            $("#pointsFee").text(data.result.pointsFee);// 积分支付
            $("#payables").text(data.result.payables);// 应付
			$("#order_prom_amount").text(data.result.order_prom_amount);// 订单 优惠活动
        }
    });
}
function ajax_address(){
	$.ajax({
		url:"{:U('Mobile/Cart/ajaxAddress')}",//+tab,
		success: function(data){
			$("#ajax_address").html('');
			$("#ajax_address").append(data);

		}
	});
	ajax_order_price();

}

// 提交订单
ajax_return_status = 1; // 标识ajax 请求是否已经回来 可以进行下壹次请求
function submit_order()
{
	if(ajax_return_status == 0)
	    return false;

	ajax_return_status = 0;

    $.ajax({
        type : "POST",
        url:"{:U('Mobile/Cart/cart3')}",//+tab,
        data : $('#cart2_form').serialize()+"&act=submit_order",// 妳的formid
        dataType: "json",
        success: function(data){

            if(data.status != '1')
            {
                alert(data.msg); //执行有误
                // 登录超时
                if(data.status == -100)
                    location.href ="{:U('Mobile/User/login')}";

				ajax_return_status = 1; // 上壹次ajax 已经返回, 可以进行下壹次 ajax请求

                return false;
            }
            // console.log(data);
            $("#postFee").text(data.result.postFee); // 物流费
            $("#couponFee").text(data.result.couponFee);// 优惠券
            $("#balance").text(data.result.balance);// 余额
            $("#pointsFee").text(data.result.pointsFee);// 积分支付
            $("#payables").text(data.result.payables);// 应付
			$("#order_prom_amount").text(data.result.order_prom_amount);// 订单 优惠活动
            alert('订单提交成功，跳转支付页面!');
			gopayweixin(data.result);
            //location.href = "/index.php?m=Mobile&c=Cart&a=cart4&order_id="+data.result;

        }
    });
}
</script>
</body>
</html>